<?php
class AuctionMarkDao{
	public $auction_id;
	public $_auctionMarker;
	
	public function __construct(){
		$this->_auctionMarker=new AutobidMark();
	}
	
	
	public function add($key='has',$value=1){
		$id=$this->auction_id.':'.$key;
		$markSql = '
            INSERT INTO
                autobid_mark
            VALUES (
                "' . $id . '",
                "' . $value . '"
            )
            ON DUPLICATE KEY UPDATE
                autobid_mark.id = "' . $id . '"
        ';
		return Yii::app()->db->createCommand($markSql)->execute();
	}
	
	
	public function get($key='has'){
		$mark=$this->_auctionMarker->findByPk($this->auction_id.':'.$key);
		if (!empty($mark)) {
			return $mark->value;
		}
		return false;
	}
	
	
	public function del($key='has'){
		return $this->_auctionMarker->deleteByPk($this->auction_id.':'.$key);
	}
}